/**
 * @fileName:router
 * @decription:
 * @author: hanzhendong
 * @Date: 16/3/21
 * @Time: 上午11:02
 */
angular.module('antLink').config(function ($stateProvider, $urlRouterProvider, $locationProvider) {

    $urlRouterProvider.otherwise("/index");
    $stateProvider
        .state('index', {
            url: '/index',
            templateUrl: 'fullpage.html',
            controller: function ($scope) {
                $scope.dynamicPopover = {
                    templateUrl: 'onesweep.html',
                    title: '扫描有惊喜!'
                };
                $('#fullpage').fullpage({
                    anchors: ['firstPage', 'secondPage', '3rdPage', '4rdPage', '5rdPage', '6rdPage'],
                    sectionsColor: ['#EDDAA5', '#eded84', '#88dbee', '#eded84', '#88dbee', '#eded84'],
                    navigation: true,
                    // lockAnchors: true,
                    navigationPosition: 'right',
                    navigationTooltips: ['校园集结号', '学习必备', '校园助手', '附近同学', '活动组织', '失物招领'],
                    'verticalCentered': false,
                    'afterLoad': function (anchorLink, index) {
                        function addAnimated($jq, Animate) {
                            $jq.addClass(Animate);
                        }

                        function removeAnimated($jq, Animate) {
                            $jq.removeClass(Animate);
                        }

                        switch (index) {
                            case 1:
                                addAnimated($('.section1 img'), 'animated zoomInDown');
                                setTimeout(function () {
                                    (function () {
                                        removeAnimated($('.section1 img'), 'animated zoomInDown');
                                    })()
                                }, 3000);
                                addAnimated($('.section1 img'), 'animated flash animatetwo');
                                break;
                            case 2:
                                //$scope.flag = true;
                                addAnimated($('.section2 h1'), 'animated fadeInRight');
                                addAnimated($('.section2 p'), 'animated fadeInLeft');
                                break;
                            case 3:
                                addAnimated($('.section3 h1'), 'animated bounce');
                                addAnimated($('.section3 p'), 'animated bounce');
                                break;
                            case 4:
                                addAnimated($('.section4 h1'), 'animated rollIn');
                                addAnimated($('.section4 p'), 'animated rollIn');
                                break;
                            case 5:
                                addAnimated($('.section5 h1'), 'animated zoomIn');
                                addAnimated($('.section5 p'), 'animated zoomIn');
                                break;
                            case 6:
                                addAnimated($('.section6 h1'), 'animated zoomInRight');
                                addAnimated($('.section6 p'), 'animated zoomInLeft');
                                break;
                        }
                    },

                    'onLeave': function (index, nextIndex, direction) {
                        function removeAnimated($jq, Animate) {
                            $jq.removeClass(Animate);
                        }

                        switch (index) {
                            case 1:
                                removeAnimated($('.section1 img'), 'animated zoomInDown');
                                removeAnimated($('.section1 img'), 'animated flash animatetwo');
                                break;
                            case 2:
                                removeAnimated($('.section2 h1'), 'animated fadeInRight');
                                removeAnimated($('.section2 p'), 'animated fadeInLeft');
                                break;
                            case 3:
                                removeAnimated($('.section3 h1'), 'animated bounce');
                                removeAnimated($('.section3 p'), 'animated bounce');
                                break;
                            case 4:
                                removeAnimated($('.section4 h1'), 'animated rollIn');
                                removeAnimated($('.section4 p'), 'animated rollIn');
                                break;
                            case 5:
                                removeAnimated($('.section5 h1'), 'animated zoomIn');
                                removeAnimated($('.section5 p'), 'animated zoomIn');
                                break;
                            case 6:
                                removeAnimated($('.section6 h1'), 'animated zoomInRight');
                                removeAnimated($('.section6 p'), 'animated zoomInLeft');
                                break;


                        }
                    }
                });
            }
        })

        .state('collaboration', {
            url: '/collaboration',
            views: {
                '': {
                    templateUrl: 'collaboration.html',
                    controller: function ($scope) {
                        $scope.pageClass = "antlink";
                        $scope.pageFooter = 'page-footer.html';
                        $scope.slides = [
                            {image: 'http://7xse0o.com1.z0.glb.clouddn.com/resources/images/collaboration/banner.png', text: ''}];
                        $.fn.fullpage.destroy('all');
                    }
                },
                'carousel@collaboration': {
                    templateUrl: 'carousel.html',
                }
            },
        })
        .state('download', {
            url: '/download',
            views: {
                '': {
                    templateUrl: 'downloadTpl.html',
                    controller: function ($scope) {
                        $scope.pageClass = "antlink";
                        $scope.pageFooter = 'page-footer.html';
                        $scope.slides = [
                            {image: 'http://7xse0o.com1.z0.glb.clouddn.com/resources/images/download/about_banner.png', text: ''}];
                        $.fn.fullpage.destroy('all');
                    }
                },
                'carousel@download': {
                    templateUrl: 'carousel.html',
                }
            }
        })
        .state('aboutUs', {
            url: '/aboutUs',
            views: {
                '': {
                    templateUrl: 'aboutUs.html',
                    controller: function ($scope) {
                        $scope.pageClass = "antlink";
                        $scope.pageFooter = 'page-footer.html';
                        $scope.slides = [
                            {image: 'http://7xse0o.com1.z0.glb.clouddn.com/resources/images/about/about_banner.png', text: ''}];
                        var jinan = new BMap.Point(117.137363, 36.680568);
                        var opts = {
                            position: jinan,
                            offset: new BMap.Size(-10, -65)
                        };
                        var map = new BMap.Map("allmap");
                        map.centerAndZoom(jinan, 16);
                        var mk = new BMap.Marker(jinan);
                        map.addOverlay(mk);
                        map.panTo(jinan);
                        mk.setAnimation(BMAP_ANIMATION_BOUNCE);
                    /*    var label = new BMap.Label("&nbsp;蚁动科技欢迎您的加入!", opts);
                        label.setStyle({
                            color: "red",
                            solid: true,
                            fontSize: "24px",
                            fontFamily: "微软雅黑"
                        });
                        map.addOverlay(label);*/
                        map.setCurrentCity("济南");
                        map.enableScrollWheelZoom(true);
                        $.fn.fullpage.destroy('all');
                    }
                },
                'carousel@aboutUs': {
                    templateUrl: 'carousel.html',
                }
            }
        })
        .state('joinUs', {
            url: '/joinUs',
            views: {
                '': {
                    templateUrl: 'joinUs.html',
                    controller: function ($scope) {
                        $scope.pageClass = "antlink";
                        $scope.pageFooter = 'tpl/page-footer.html';
                        $scope.slides = [
                            {image: 'http://7xse0o.com1.z0.glb.clouddn.com/resources/images/banner.png', text: ''}];
                        $.fn.fullpage.destroy('all');
                    }
                },
                'carousel@joinUs': {
                    templateUrl: 'carousel.html',
                }
            }
        });
})